// pages/song/song.js
var song = wx.createInnerAudioContext()
Page({

  data: {
    play:true
  },

  onLoad: async function (options) {
    var id = options.id;
    var module = await import("../../utils/http");
    var res = await module.Url.songUrl(id);
    var url;
    res.data.data.forEach(item=>{
      url = item.url
    })
    song.src=url;
    song.play();
  },
  pause(){
    var play = !this.data.play;
    this.setData({play});
    this.handlePlay(play);
  },
  handlePlay(play){
    if(play){
      song.play();
    }else if(!play){
      song.pause();
    }
  }
})